/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aletex.config;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author cibervn
 */
public class ConfigFacade implements Serializable {

    private static final Map<String, String> params = new HashMap<String, String>();
    private static final String fileName = "config.txt";

    static {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));
            String line;
            while ((line = br.readLine()) != null) {
                String values[] = line.split(":");
                params.put(values[0], values[1]);
            }
        } catch (Exception e) {
            Logger.getLogger(ConfigFacade.class.getName()).log(Level.SEVERE, e.getMessage());
        }
    }

    public static String getParam(String key) throws LoadConfigException {
        try {
            return params.get(key);
        } catch (Exception e) {
            throw new LoadConfigException(e.getMessage());
        }
    }
}
